package model

import (
	"gorm.io/gorm"
	"time"
	"wechat-moments_0926/config"
)

type Like struct {
	Id        uint32         `gorm:"column:id;type:int UNSIGNED;comment:id;primaryKey;not null;" json:"id"` // id
	FeedId    int32          `gorm:"column:feed_id;type:int;comment:动态ID;not null;" json:"feed_id"`         // 动态ID
	UserId    int32          `gorm:"column:user_id;type:int;comment:用户ID;not null;" json:"user_id"`         // 用户ID
	CreatedAt time.Time      `gorm:"column:created_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"created_at"`
	UpdatedAt time.Time      `gorm:"column:updated_at;type:datetime(3);not null;default:CURRENT_TIMESTAMP(3);" json:"updated_at"`
	DeletedAt gorm.DeletedAt `gorm:"column:deleted_at;type:datetime(3);default:NULL;" json:"deleted_at"`
}

func (l *Like) TableName() string {
	return "like"
}

func (l *Like) AddLike() error {
	return config.DB.Create(&l).Error
}
